#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <vector>
#include <thread>
#include "TaskQueue.hpp"
#include <functional>
using std::vector;
using std::thread;

class ThreadPool{
    using Elemtype = std::function<void()>;
public:
    ThreadPool(int threadnum,int task_capa);
    ~ThreadPool();
    void start(); //开启子线程
    void stop();    //停止子线程
    void addTask(Elemtype &&elem);
    void doTask(); //子线程的入口函数
private:
    int _threadnum;
    vector<thread> threads;
    int _capacity;
    TaskQueue _taskQue;
    bool isExit;
};



#endif

